<?php
/**
 * Matteo Vigoni <mattevigo@gmail.com>
 *
 * New blogpost script
 */
defined( "_ENTRY_") or die( "Restricted Access" );

import("core.blog.Blogpost");

$db = getDB();
$user = getUser( &$db );

$location = "location: admin.php?option=add_blogpost";

$blogpost = NULL; // Blogpost Object

$blogpost_body = get_var( "blogpost_body", "post", NULL );
$blogpost_id = get_var( "blogpost_id", "post", NULL );
$class = get_var( "class", "post", "Blogpost" );

if ( ( $blogpost_body == NULL ) || ( strcmp( $blogpost_body, "") == 0) )
{
	set_error( "The post is empty.");

	header($location);
	exit();
}
else
{
	try
	{
		// Blogpost //////////////////////////////
		$blogpost = new $class( &$db, $blogpost_id );

		$blogpost->doPost( &$user );
		$blogpost->store();
				
		// Categories /////////////////////////////
		
		// Tags ///////////////////////////////////
		
		///////////////////////////////////////////
		
		set_message("Post success");
	}
	catch( Exception $e )
	{
		set_error( $e->getMessage() );
		header( $location );
		exit();
	}

}

// SOCIAL NETWORKS /////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////

header( $location );
?>